# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
from hanziconv import HanziConv


class RealestatecommitteePipeline(object):
    def process_item(self, item, spider):
        return item


class HanziconvPipeline(object):

    def process_item(self, item, spider):
        for key, value in item.items():
            if value is not None:
                if isinstance(value, unicode):
                    value = HanziConv.toTraditional(str(value))
                    print key, value
                    item[key] = value
                else:  # 不为中文不处理
                    pass
            else:  # value为None 初始化为空串
                item[key] = ""
        return item
